<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>你办囍事 我送囍酒</title>
		<meta name="viewport" content="width=640,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="/Public/game/css/reset.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/Redeem.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/animate.css" />
	</head>

	<body>
		<?php
 $jssdk = new \JSSDK("wxfd8742a962585bcd", "1390437b5921430a49b529c4a79aba62"); $signPackage = $jssdk->GetSignPackage(); ?>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId:  '<?php echo $signPackage["appId"];?>', // 必填，公众号的唯一标识
        timestamp:<?php echo $signPackage["timestamp"];?>, // 必填，生成签名的时间戳
        nonceStr: '<?php echo $signPackage["nonceStr"];?>', // 必填，生成签名的随机串
        signature: '<?php echo $signPackage["signature"];?>',// 必填，签名，见附录1
        jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function () {
        initShareTimeline();
        initShareAppMessage();
//      music.play();
    });


/**
 * 初始化分享到朋友圈的设置
 */
function initShareTimeline(title,link,imgUrl){
	title= title?title:"<?php echo $BanquetUserInfo['name'];?>要结婚了，快来Ta的婚宴抢个座！";
	link= link?link:"<?php echo \Org\Net\Fun::url('home/page/table',array('id'=>$BanquetInfo['id'])); ?>";
	imgUrl = imgUrl?imgUrl:"<?php echo C('HTTP_HOST_URL');?>/Public/images/share.png";
    //分享到朋友圈
    wx.onMenuShareTimeline({
        title: title, // 分享标题
        link: link, // 分享链接
        imgUrl: imgUrl, // 分享图标
        trigger: function(res) {
		// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
		//              alert('用户点击分享到朋友圈');
            
		},
		success: function(res) {
            <?php if($BanquetUserInfo['wx_id']==$userInfo['wx_id']):?>
            if(showwel){
            		try{
            			if (typeof(eval("showwel")) == "function") {
			           showwel(3);
			        }
            		}catch(e){
            			
            		}
            }
            
            <?php endif;?>
//			sharelog();
			///////////////////////////////////////////////
//			close_mask();
            
            
		},
		cancel: function(res) {
		},
		fail: function(res) {
		}
    });
}


/**
 * 初始化分享好友的设置
 */
function initShareAppMessage(title,desc,link,imgUrl){ 
	
	title= title?title:"<?php echo $BanquetUserInfo['name'];?>要结婚了，快来Ta的婚宴抢个座！";
	desc=desc?desc:"你办囍事，我送囍酒";
	link= link?link:"<?php echo \Org\Net\Fun::url('home/page/table',array('id'=>$BanquetInfo['id'])); ?>";
	imgUrl = imgUrl?imgUrl:"<?php echo C('HTTP_HOST_URL');?>/Public/images/share.png";
	//分享给朋友
    wx.onMenuShareAppMessage({
        title: title, // 分享标题
        desc: desc, // 分享描述
        link: link, // 分享链接
        imgUrl: imgUrl, // 分享图标
		trigger: function(res) {
            
			// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
			//          alert('用户点击发送给朋友');
		},
		success: function(res) {
            <?php if($BanquetUserInfo['wx_id']==$userInfo['wx_id']):?>
             
        		try{
        			if (typeof(eval("showwel")) == "function") {
		           showwel(3);
		        }
        		}catch(e){
        			
        		}
            <?php endif;?>
//			sharelog();
			///////////////////////////////////////////////////////
//			close_mask();
            
		},
		cancel: function(res) {
		},
		fail: function(res) {
		}
    });
}
    
//提交分享记录    
function sharelog(){
	MYajax({"type":"share"},"/index.php/Home/app/share.html",function(res){})
}


//秘钥
var tokenkey = "lkasdj213489ulkjadsf";
function MYajax(requestData,url,successCallback){
	var requestData = requestData;
	var url = url;
	requestData = JSON.stringify(requestData);
	var requestKey = $.md5(requestData+tokenkey);
	$.ajax({
		type:"post",
		url:url,
		data:{'data':requestData,"key":requestKey},
		async:true,
		success:function(res){
			successCallback(res);
		},
		dataType:'json',
		fail:function(e){
			
		}
	});
}
</script>
		<div class="web"> 
			<ul>
				<li>请输入兑换码</li>
                <li><input type="text" class="code" /></li>
				<li><span class="confirm button">确 认</span></li>
			</ul>
			<div class="bot">
				<button class="goUrl"></button>
			</div>
			<div class="mask">
				<div class="box">
					<div class="result success animated bounceIn">
						<ul>
							<li><span class="remove"><img src="/Public/game/images/close_icon.jpg"/></span></li>
							<li><span class="textContent">兑换成功!</span></li>
						</ul>
					</div>
					<div class="result fail animated bounceIn">
						<ul>
							<li><span><img src="/Public/game/images/close_icon.jpg"/></span></li>
							<li>
                                <span>输入错误<br/>请注意区分字母大小写</span>
                            </li>
							<li><button>重新输入</button></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<script src="<?php echo C('HTTP_HOST_URL');?>/Public/game/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
        <script src="<?php echo C('HTTP_HOST_URL');?>/Public/game/js/jQuery.md5.js" type="text/javascript" charset="utf-8"></script>
        
		<script type="text/javascript">
            var number = 'lkasdj213489ulkjadsf';
			$(".web .confirm").on("click",function(){
                var code = $(".code").val();
                var postData = {"code":code};
                var qwer = JSON.stringify(postData);
                var asdf = $.md5(qwer + number);
                var url = '<?php echo \Org\Net\Fun::url("home/page/verificationCode") ?>';

                var postData = {'qwer':qwer,"session_id":asdf};
                $.post(url,postData,function(data){
                    if(data.state==1){
                        $(".textContent").text(data.message)
                        $(".mask, .success").css("display","block");
                    } else {
                        $(".mask, .fail").css("display","block");
                    }                    
                },"json");
                
                
//				if($(".web ul:first input").val()!=""){
//					$(".mask, .success").css("display","block");
//				}else{
//					$(".mask, .fail").css("display","block");
//				}
			})
			$(".result .remove").on("click",function(){
				$(".mask").css("display","none");
			})
			$(".result.fail li:last button").on("click",function(){
				$(".mask").css("display","none");
				$(".web ul:first-of-type input").focus();
			})
			$(".result.fail li:first span").on("click",function(){
				$(".mask").css("display","none");
			});
            
            $(".goUrl").click(function(){
                location.href = "<?php echo \Org\Net\Fun::url('home/page/index'); ?>";
            });
		</script>
	</body>

</html>